package com.utils.generalConfig.controller;

import com.utils.generalConfig.pojo.GeneralConfig;
import com.utils.generalConfig.service.GeneralConfigService;
import com.utils.common.ServerResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
* 描述:
* author: srdl
* date: 2022-01-05
*/

@RestController
@RequestMapping(value="/generalConfig")
public class GeneralConfigController {

    @Autowired
    private GeneralConfigService generalConfigService;

    @GetMapping(value="/list")
    public ServerResponse list(){
        return generalConfigService.list();
    }

    @GetMapping(value="/pageList")
    public ServerResponse pageList(PageInfo pageInfo){
        return generalConfigService.pageList(pageInfo);
    }

    @GetMapping(value = "/get/{id}")
    public ServerResponse getById(@PathVariable String id){
    return generalConfigService.get(id);
    }

    @PostMapping(value = "/add")
    public ServerResponse addGeneralConfig(@RequestBody @Validated GeneralConfig generalConfig){
        return generalConfigService.addGeneralConfig(generalConfig);
    }

    @PutMapping(value = "/delete/{id}")
    public ServerResponse deleteGeneralConfig(@PathVariable String id){
        return generalConfigService.deleteGeneralConfig(id);
    }

    @PostMapping(value = "/update")
    public ServerResponse updateGeneralConfig(@RequestBody @Validated GeneralConfig generalConfig){
        return generalConfigService.updateGeneralConfig(generalConfig);
    }

    @GetMapping(value = "/getByCode/{code}")
    public ServerResponse getByCode(@PathVariable String code){
        return generalConfigService.getByCode(code);
    }

}
